package com.ssy.lingxi.member.merchant.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.dataauth.annotation.member.MemberAuth;
import com.ssy.lingxi.member.merchant.model.vo.basic.request.*;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.CountryAreaCodeNameVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.LevelAndTagVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.MemberConfigGroupVO;
import com.ssy.lingxi.member.merchant.model.vo.basic.response.RoleIdAndNameVO;
import com.ssy.lingxi.member.merchant.model.vo.maintenance.response.*;
import com.ssy.lingxi.member.merchant.model.vo.validate.request.*;
import com.ssy.lingxi.member.merchant.service.web.IMemberAbilityImportService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 会员能力 - 会员导入相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2020-08-27
 */
@RestController
@RequestMapping("/member/ability/sub")
public class MemberAbilityImportController {
    @Resource
    private IMemberAbilityImportService memberAbilityImportService;

    /**
     * 获取分页查询会员列表页面中各个查询条件下拉选择框的内容
     * @param headers HttpHeaders信息
     * @return 操作结果
     */
    @RequestMapping(value = "/pageitems", method = RequestMethod.GET)
    public Wrapper<MemberImportSearchConditionVO> getPageCondition(@RequestHeader HttpHeaders headers) {
        return memberAbilityImportService.getPageCondition(headers);
    }

    /**
     * 分页、模糊查询会员
     * @param headers HttpHeaders信息
     * @param queryVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    @MemberAuth
    public Wrapper<PageData<MemberAbilityImportPageQueryVO>> pageMembers(@RequestHeader HttpHeaders headers, @Valid MemberAbilityImportMemberQueryVO queryVO) {
        return memberAbilityImportService.pageMembers(headers, queryVO);
    }


    /**
     * 获取新增会员页面内容（审核步骤、会员类型、手机号前缀）
     * @param headers HttpHeaders信息
     * @return 操作结果
     */
    @RequestMapping(value = "/pageitems/basic", method = RequestMethod.GET)
    public Wrapper<MemberAbilityAddMemberPageItemsVO> getAddMemberPageItems(@RequestHeader HttpHeaders headers) {
        return memberAbilityImportService.getAddMemberPageItems(headers);
    }

    /**
     * 新增会员页面，根据会员类型，查询角色列表
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/pageitems/role", method = RequestMethod.GET)
    public Wrapper<List<RoleIdAndNameVO>> getAddMemberPageRoles(@RequestHeader HttpHeaders headers, @Valid MemberTypeIdVO idVO) {
        return memberAbilityImportService.getAddMemberPageRoles(headers, idVO);
    }

    /**
     * 新增会员页面，根据会员类型和角色，查询等级列表
     * @param headers HttpHeaders信息
     * @param typeAndRoleIdVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/pageitems/level", method = RequestMethod.GET)
    public Wrapper<List<LevelAndTagVO>> getAddMemberPageLevels(@RequestHeader HttpHeaders headers, @Valid MemberTypeAndRoleIdVO typeAndRoleIdVO) {
        return memberAbilityImportService.getAddMemberPageLevels(headers, typeAndRoleIdVO);
    }


    /**
     * 新增会员页面，选择会员类型为渠道会员时，返回渠道信息
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/pageitems/channel", method = RequestMethod.GET)
    public Wrapper<MemberAbilityAddMemberPageChannelVO> getAddMemberPageChannelItems(@RequestHeader HttpHeaders headers, @Valid MemberTypeIdVO idVO) {
        return memberAbilityImportService.getAddMemberPageChannelItems(headers, idVO);
    }

    /**
     * 新增渠道会员时，根据上级会员Id，查询省列表
     * @param headers Http头部信息
     * @param idVO 接口参数
     * @return 返回信息
     */
    @RequestMapping(value = "/pageitems/province", method = RequestMethod.GET)
    public Wrapper<List<CountryAreaCodeNameVO>> getProvinceList(@RequestHeader HttpHeaders headers, @Valid UpperRelationIdVO idVO) {
        return memberAbilityImportService.getProvinceList(headers, idVO);
    }

    /**
     * 新增渠道会员时，根据上级会员Id和省编码，查询市列表
     * @param headers Http头部信息
     * @param codeVO 接口参数
     * @return 返回信息
     */
    @RequestMapping(value = "/pageitems/city", method = RequestMethod.GET)
    public Wrapper<List<CountryAreaCodeNameVO>> getCityList(@RequestHeader HttpHeaders headers, @Valid UpperRelationIdAndAreaCodeVO codeVO) {
        return memberAbilityImportService.getCityList(headers, codeVO);
    }

    /**
     * 新增会员页面，根据选择的角色，返回会员注册资料信息
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/pageitems/detail", method = RequestMethod.GET)
    public Wrapper<List<MemberConfigGroupVO>> getAddMemberPageMemberConfigItems(@RequestHeader HttpHeaders headers, @Valid RoleIdVO idVO) {
        return memberAbilityImportService.getAddMemberPageMemberConfigItems(headers, idVO);
    }

    /**
     * 新增会员
     * @param headers HttpHeaders信息
     * @param memberVO 接口参数
     * @return 操作结果
     */
    @RequestMapping("/add")
    public Wrapper<Void> addSubMember(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberAbilityAddMemberVO memberVO) {
        return memberAbilityImportService.addSubMember(headers, memberVO);
    }

    /**
     * 引入单个/多个会员
     * @param headers HttpHeaders信息
     * @param memberVO 接口参数
     * @return 操作结果
     */
    @RequestMapping("/introduce")
    public Wrapper<Void> introduceSubMember(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberAbilityAddMemberListVO memberListVO) {
        return memberAbilityImportService.introduceSubMember(headers, memberListVO);
    }

    /**
     * 查询单个会员详细信息
     * @param headers HttpHeaders信息
     * @param validateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public Wrapper<MemberAbilityImportMemberDetailVO> getSubMember(@RequestHeader HttpHeaders headers, @Valid MemberValidateVO validateVO) {
        return memberAbilityImportService.getSubMember(headers, validateVO);
    }

    /**
     * 修改会员信息
     * @param headers HttpHeaders信息
     * @param updateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping("/update")
    public Wrapper<Void> updateSubMember(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberAbilityUpdateMemberVO updateVO) {
        return memberAbilityImportService.updateSubMember(headers, updateVO);
    }

    /**
     * 删除会员
     * @param headers HttpHeaders信息
     * @param validateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping("/delete")
    public Wrapper<Void> deleteSubMember(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberValidateVO validateVO) {
        return memberAbilityImportService.deleteSubMember(headers, validateVO);
    }

    /**
     * 提交平台审核
     * @param headers HttpHeaders信息
     * @param validateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping("/commit")
    public Wrapper<Void> commitSubMemberToValidate(@RequestHeader HttpHeaders headers, @RequestBody @Valid MemberValidateVO validateVO) {
        return memberAbilityImportService.commitSubMemberToValidate(headers, validateVO);
    }

    /**
     * 会员详情
     * @param headers HttpHeaders信息
     * @param validateVO 接口参数
     * @return 操作结果
     */
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public Wrapper<MemberAbilityImportMemberTextDetailVO> getSubMemberDetail(@RequestHeader HttpHeaders headers, @Valid MemberValidateVO validateVO) {
        return memberAbilityImportService.getSubMemberDetail(headers, validateVO);
    }
}
